package org.example.judge.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.example.judge_common.rank.AllUserRank;
import org.example.judge_pojo.Submit;

import java.util.List;

public interface SubmitMapper extends BaseMapper<Submit> {

    /**
     * 获取用户通过题目数量信息
     * @param begin
     * @param end
     * @return
     */
    @Select("SELECT user_id,COUNT(DISTINCT problem_id) as accept_sum FROM `tb_submit`" +
            " where error_status = 0 and create_time >= #{beginTime} GROUP BY user_id ORDER BY accept_sum desc limit #{begin},#{end}")
    List<AllUserRank> getAllRankSumbit(int begin,int end,String beginTime);

    /**
     * 获取用户未通过的题目ids
     * @param userId
     * @return
     */
    @Select("select distinct problem_id from tb_submit where user_id = #{userId} and problem_id not in  (" +
            "select distinct problem_id from tb_submit where user_id = #{userId} and error_status=0" +
            ")")
    @Deprecated
    List<String> getNotAcceptProblemIds(String userId);
}
